Skip to content

Comments

Add additional safelist regex variations#7674

Closed
mrinx wants to merge 2 commits intotailwindlabs:masterfrom
mrinx:regex-safelist
Closed

Add additional safelist regex variations#7674
mrinx wants to merge 2 commits intotailwindlabs:masterfrom
mrinx:regex-safelist

Conversation

@mrinx
Copy link
Contributor

@mrinx mrinx commented Feb 26, 2022

This pull request is trying to bring a new way of doing regex safelisting, and to allow for color opacities in a safelist with regex (#6770).

The current format:

safelist: [
  {
    pattern: /bg-(red)-(100|200)/,
    variants: ['hover'],
  },
],

The new formats:

safelist: [
  {
    pattern: [['hover'], /bg-(red)-(100|200)/, ['50']],
    pattern: [['hover'], /bg-(green)-(100|200)/],
    pattern: [/bg-(blue)-(100|200)/, ['50']],
    pattern: [/bg-(yellow)-(100|200)/],
  },
],
safelist: [
  /bg-(red)-(100|200)/,
],
safelist: [
  [['hover'], /bg-(red)-(100|200)/, ['50']],
  [['hover'], /bg-(green)-(100|200)/],
  [/bg-(blue)-(100|200)/, ['50']],
  [/bg-(yellow)-(100|200)/],
],

@adamwathan, is this something you had in mind (#7582)?

@adamwathan
Copy link
Member

Awesome thank you! I made a couple small tweaks to remove support for this option:

safelist: [
  {
    pattern: [['hover'], /bg-(red)-(100|200)/, ['50']],
    pattern: [['hover'], /bg-(green)-(100|200)/],
    pattern: [/bg-(blue)-(100|200)/, ['50']],
    pattern: [/bg-(yellow)-(100|200)/],
  },
],

...just because thinking about it again I just don't see a reason to support it, better to just use the top-level tuple format.

Going to review this idea with the team this week before merging but I think this is going to be an improvement, thanks again.

@adamwathan
Copy link
Member

Hey thanks again for this! Decided on a slightly different approach which we've opened a PR for here:

#8774

So going to close this, but included you as a co-author on that one for your efforts here ❤️

@adamwathan adamwathan closed this Jul 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants